<?php
class Application_Model_DiaValorTotal extends Zend_Db_Table_Abstract
{
	// Table Name
	protected $_name = 'dia_valor_total';
	// Primary Key
	protected $_primary = 'id_dia_valor_total';
	
	// Insert
	public function insert(array $data)
	{
		return	parent::insert($data);
	}
	
	// Update
	public function update(array $data, $where)
	{
		return parent::update($data, $where);
	}
	
	// Delete
	public function delete($where)
	{
		return parent::delete($where);
	}
	
	public function selectAll()
	{
		$select = $this->select()->setIntegrityCheck(false);
		
		$select->from(array('dv' => $this->_name), array('dv.id_dia_valor_total','dv.id_dia','dv.valor'));
		
		$select->joinRight(array('d' => 'dia'), 'd.id_dia = dv.id_dia',array('d.dia'));
		
		return $this->fetchAll($select);
	}
	
	public function selectDay($dia = null)
	{
		$select = $this->select()->setIntegrityCheck(false);
		
		$select->from(array('dv' => $this->_name), array('dv.id_dia_valor_total','dv.id_dia','dv.valor'));
		
		$select->joinRight(array('d' => 'dia'), 'd.id_dia = dv.id_dia',array('d.dia'));
		
		$select->where('d.dia = ?',$dia);

		return $this->fetchRow($select);
	}
}